package com.haipumi.back.actions;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;

import com.haipumi.beans.DataGrid;
import com.haipumi.beans.haipumi_chatInfo;
import com.haipumi.biz.IBackChatInfoBiz;
import com.haipumi.biz.impl.BackChatInfoBizImpl;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;

@Controller("chatInfoAction")
public class ChatInfoAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2085822435918372719L;

	@Autowired
	IBackChatInfoBiz backChatInfoBiz;
	
	DataGrid dg=new DataGrid();
	

	public DataGrid getDg() {
		return dg;
	}

	public void setDg(DataGrid dg) {
		this.dg = dg;
	}
	
	public String doChat(){
		String op=null;
		HttpServletRequest request=ServletActionContext.getRequest();
		HttpServletResponse response=ServletActionContext.getResponse();
		op=request.getParameter("op");
		if("findallchatinfo".equals(op)){			
			findallchatinfo(request,response);
		}
		return Action.SUCCESS;
	}

	private void findallchatinfo(HttpServletRequest request,HttpServletResponse response){
		List<haipumi_chatInfo>chatinfolist=null;
		chatinfolist=backChatInfoBiz.findAllChatInfo();
		int r=0;
		r=backChatInfoBiz.countAllChatInfo();
		
		dg.setRows(chatinfolist);
		dg.setTotal(r);
	}
}
